package com.nondo.rdp.finance.repository.circle;

import com.nondo.rdp.core.common.StatusConstant;
import com.nondo.rdp.finance.domain.circle.CircleUp;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface CircleUpRepository extends JpaRepository<CircleUp, Long>, JpaSpecificationExecutor<CircleUp> {
    @Modifying
    @Query("update CircleUp set delFlag='" + StatusConstant.DEL_FLAG_DELETE + "' where id = ?1")
    void deleteById(Long id);

    CircleUp save(CircleUp activity);

    @Query("select c from CircleUp c where c.circle.id=:cid and c.user.id=:uid and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
	CircleUp findCircleUpByCircleAndUser(@Param("cid") long cid, @Param("uid") long uid);
}
